<template>
    <div class="photoInfoContainer">
        <h3>{{photoInfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间: {{photoInfo.add_time}}</span>
            <span>点击： {{photoInfo.click}}次</span>
        </p>
        <hr>
        <!-- 缩略图区域 -->
        <!-- <img class="preview-img" v-for="(item,index) in list" :src="item.src" @click="$preview.open(index,list)" height="100" :key="item.id"> -->
        
        <div class="picList">
            <vue-preview :slides="list" class="preview" ></vue-preview>
        </div>
        <!-- 图片内容区域 -->
        <div class="content" v-html="photoInfo.content">

        </div>
        <!-- 评论子组件 -->
        <comment></comment>
    </div>     
</template>   
<script>
import comment from '../subcomponents/comment.vue'
export default {
    data() {
        return {
            id: this.$route.params.id,
            photoInfo: {},
            list: []  //缩略图数组
        }
    },
    created(){
        this.getPhotoInfo();
        this.getThumbs();
    },
    methods: {
        getPhotoInfo(){
            //获取图片详情
            this.$http.get("src/json/photoList"+ this.id+".json").then(result =>{
                if(result.body.status === 0){
                    this.photoInfo = result.body.message[0];
                    console.log(photoInfo);
                }
            })
        },
        getThumbs(){
            this.$http.get("src/json/photo.json").then(result => {
                if(result.body.status === 0){
                    result.body.message.forEach(element => {
                        element.w = "600";  //vue-preview使用必须添加的条件
                        element.h = "400";
                        element.msrc = element.src;
                    });
                    this.list = result.body.message;
                }
            })
        }
    },
    components: {
        comment
    }
}
</script>
<style lang="scss" >
    .photoInfoContainer{
        padding: 3px;
        h3{
            color: #26A2FF;
            font-size: 15px;
            text-align: center;
            margin: 15px 0;
        }
        .subtitle{
            display: flex;
            justify-content: space-between;
        }
        .content{
            font-size: 13px;
            line-height: 30px;
        }
        .picList .my-gallery
        {
            display: flex;
            flex-wrap: wrap;

            figure{
            margin: 0px;
            box-shadow: 0 0 10px #ccc;
            img{
                width: 100px;
                height: 80px

            }
            }
        }
    }
</style>